* Rolling estimaitons command FS
rolling in 1/120089, window(250) clear noisily : reg cds rvc l.rvc, noconst
rolling in 1/120089, window(250) clear noisily : reg cds rvj l.rvj, noconst

* On differences HR
* original estimations of beta:
*rolling in 1/75240, window(250) clear noisily : reg cds d.rvc l.d.rvc, vce(cluster firm) noconst
*rolling in 1/75240, window(250) clear noisily : reg cds d.rvj l.d.rvj, vce(cluster firm) noconst
* new for returns:
rolling in 1/75240, window(250) clear noisily : reg d.cds d.rvc l.d.rvc d.lambda l.d.lambda if dum==1, noconst
rolling in 1/75240, window(250) clear noisily : reg d.cds d.rvj l.d.rvj d.lambda l.d.lambda if dum==1, noconst

rolling in 1/75240, window(250) clear noisily : reg d.cds d.rvc l.d.rvc d.lambda l.d.lambda if dum==2, noconst
rolling in 1/75240, window(250) clear noisily : reg d.cds d.rvj l.d.rvj d.lambda l.d.lambda if dum==2, noconst

* Second stage Fama-McBeth ( I have already estimated B-loadings in the first stage)
xtreg cds rvc_betaloadings def, vce(cluster quintiles)
estimates store m1

xtreg cds rvc_betaloadings term, vce(cluster quintiles)
estimates store m2

xtreg cds rvc_betaloadings def term, vce(cluster quintiles)
estimates store m3

xtreg cds rvjbetaloadings def, vce(cluster quintiles)
estimates store m4

xtreg cds rvjbetaloadings term, vce(cluster quintiles)
estimates store m5

xtreg cds rvjbetaloadings def term, vce(cluster quintiles)
estimates store m6

xtreg cds rvc_betaloadings rvjbetaloadings def term, vce(cluster quintiles)
estimates store m7

estout m1 m2 m3 m4 m5 m6 m7 using ${path_table}FamaMacBeth2ndstage_2015.tex, cells(b(star fmt(%9.3f)) t(par)) stats(r2 N, labels("R-squared" "N") fmt(%9.2f %9.0g) ) starlevels(* 0.1 ** 0.05 *** 0.01) label collabels(, none) varlabels( "rv"	"rvc" "rvj"	"bad_jump_s" "good_jump_s" "h_vola_s" "h_skew_s" "h_kurt_s") varwidth(16) modelwidth(12) delimiter("&") mlabels((1) (2) (3) (4)(5) (6) (7)) prehead(\begin{tabular}{l*{@M}{c}} \hline \hline) postfoot(\hline \hline \end{tabular}) style(tex) substitute(_ \_) order() replace
drop _est_m1 _est_m2 _est_m3 _est_m4 _est_m5 _est_m6 _est_m7

* ------------------ Robustness FS  -------------------------------------
xtreg cds rvc_betaloadings bad_jump good_jump lambda h_vola_s h_skew_s h_kurt_s mktrf def term  , vce(cluster quintiles) 
estimates store m1

xtreg cds rvjbetaloadings bad_jump good_jump lambda h_vola_s h_skew_s h_kurt_s mktrf def term  , vce(cluster quintiles) 
estimates store m2

xtreg cds rvc_betaloadings rvjbetaloadings bad_jump good_jump lambda h_vola_s h_skew_s h_kurt_s mktrf def term  , vce(cluster quintiles) 
estimates store m3

estout m1 m2 m3  using ${path_table}Robust_FS_FamaMacBeth2ndstage_2015.tex, cells(b(star fmt(%9.3f)) t(par)) stats(r2 N, labels("R-squared" "N") fmt(%9.2f %9.0g) ) starlevels(* 0.1 ** 0.05 *** 0.01) label collabels(, none) varlabels( "rv"	"rvc" "rvj"	"bad_jump_s" "good_jump_s" "h_vola_s" "h_skew_s" "h_kurt_s") varwidth(16) modelwidth(12) delimiter("&") mlabels((1) (2) (3)) prehead(\begin{tabular}{l*{@M}{c}} \hline \hline) postfoot(\hline \hline \end{tabular}) style(tex) substitute(_ \_) order() replace
drop _est_m1 _est_m2 _est_m3


* --------------       Horce Race ------------------------------
***************      CDS Beta Loadings ****************************
xtreg cds beta_rvc_cds def, vce(cluster quintiles)
estimates store m1

xtreg cds beta_rvc_cds term, vce(cluster quintiles)
estimates store m2

xtreg cds beta_rvc_cds def term, vce(cluster quintiles)
estimates store m3

xtreg cds beta_rvj_cds def, vce(cluster quintiles)
estimates store m4

xtreg cds beta_rvj_cds term, vce(cluster quintiles)
estimates store m5

xtreg cds beta_rvj_cds def term, vce(cluster quintiles)
estimates store m6

xtreg cds beta_rvc_cds beta_rvj_cds def term, vce(cluster quintiles)
estimates store m7

estout m1 m2 m3 m4 m5 m6 m7 using ${path_table}HR_cds_FamaMacBeth2ndstage_2015.tex, cells(b(star fmt(%9.3f)) t(par)) stats(r2 N, labels("R-squared" "N") fmt(%9.2f %9.0g) ) starlevels(* 0.1 ** 0.05 *** 0.01) label collabels(, none) varlabels( "rv"	"rvc" "rvj"	"bad_jump_s" "good_jump_s" "h_vola_s" "h_skew_s" "h_kurt_s") varwidth(16) modelwidth(12) delimiter("&") mlabels((1) (2) (3) (4)(5) (6) (7)) prehead(\begin{tabular}{l*{@M}{c}} \hline \hline) postfoot(\hline \hline \end{tabular}) style(tex) substitute(_ \_) order() replace
drop _est_m1 _est_m2 _est_m3 _est_m4 _est_m5 _est_m6 _est_m7

***************      Equity Beta Loadings  ****************************
xtreg cds beta_rvc_eq def, vce(cluster quintiles)
estimates store m1

xtreg cds beta_rvc_eq term, vce(cluster quintiles)
estimates store m2

xtreg cds beta_rvc_eq def term, vce(cluster quintiles)
estimates store m3

xtreg cds beta_rvj_eq def, vce(cluster quintiles)
estimates store m4

xtreg cds beta_rvj_eq term, vce(cluster quintiles)
estimates store m5

xtreg cds beta_rvj_eq def term, vce(cluster quintiles)
estimates store m6

xtreg cds beta_rvc_eq beta_rvj_eq def term, vce(cluster quintiles)
estimates store m7

estout m1 m2 m3 m4 m5 m6 m7 using ${path_table}HR_Eq_FamaMacBeth2ndstage_2015.tex, cells(b(star fmt(%9.3f)) t(par)) stats(r2 N, labels("R-squared" "N") fmt(%9.2f %9.0g) ) starlevels(* 0.1 ** 0.05 *** 0.01) label collabels(, none) varlabels( "rv"	"rvc" "rvj"	"bad_jump_s" "good_jump_s" "h_vola_s" "h_skew_s" "h_kurt_s") varwidth(16) modelwidth(12) delimiter("&") mlabels((1) (2) (3) (4)(5) (6) (7)) prehead(\begin{tabular}{l*{@M}{c}} \hline \hline) postfoot(\hline \hline \end{tabular}) style(tex) substitute(_ \_) order() replace
drop _est_m1 _est_m2 _est_m3 _est_m4 _est_m5 _est_m6 _est_m7

* --------------       Horce Race Robustness ------------------------------
***************      CDS Beta Loadings Robust ****************************

xtreg cds beta_rvc_cds bad_jump_s good_jump_s lambda_s h_vola_s h_skew_s h_kurt_s mktrf def term roe leverage dividend , vce(cluster quintiles) 
estimates store m1

xtreg cds beta_rvj_cds bad_jump_s good_jump_s lambda_s h_vola_s h_skew_s h_kurt_s mktrf def term roe leverage dividend , vce(cluster quintiles) 
estimates store m2

xtreg cds beta_rvc_cds beta_rvj_cds bad_jump_s good_jump_s lambda_s h_vola_s h_skew_s h_kurt_s mktrf def term roe leverage dividend , vce(cluster quintiles) 
estimates store m3

estout m1 m2 m3  using ${path_table}Robust_HR_cds_FamaMacBeth2ndstage_2015.tex, cells(b(star fmt(%9.3f)) t(par)) stats(r2 N, labels("R-squared" "N") fmt(%9.2f %9.0g) ) starlevels(* 0.1 ** 0.05 *** 0.01) label collabels(, none) varlabels( "rv"	"rvc" "rvj"	"bad_jump_s" "good_jump_s" "h_vola_s" "h_skew_s" "h_kurt_s") varwidth(16) modelwidth(12) delimiter("&") mlabels((1) (2) (3)) prehead(\begin{tabular}{l*{@M}{c}} \hline \hline) postfoot(\hline \hline \end{tabular}) style(tex) substitute(_ \_) order() replace
drop _est_m1 _est_m2 _est_m3 

***************      Equity Beta Loadings  ****************************
xtreg cds beta_rvc_eq bad_jump_e good_jump_e e_lambda h_vola_e h_skew_e h_kurt_e mktrf def term roe leverage dividend , vce(cluster quintiles) 
estimates store m1

xtreg cds beta_rvj_eq bad_jump_e good_jump_e e_lambda h_vola_e h_skew_e h_kurt_e mktrf def term roe leverage dividend , vce(cluster quintiles) 
estimates store m2

xtreg cds beta_rvc_eq beta_rvj_eq bad_jump_e good_jump_e e_lambda h_vola_e h_skew_e h_kurt_e mktrf def term roe leverage dividend , vce(cluster quintiles) 
estimates store m3

estout m1 m2 m3  using ${path_table}Robust_HR_eq_FamaMacBeth2ndstage_2015.tex, cells(b(star fmt(%9.3f)) t(par)) stats(r2 N, labels("R-squared" "N") fmt(%9.2f %9.0g) ) starlevels(* 0.1 ** 0.05 *** 0.01) label collabels(, none) varlabels( "rv"	"rvc" "rvj"	"bad_jump_s" "good_jump_s" "h_vola_s" "h_skew_s" "h_kurt_s") varwidth(16) modelwidth(12) delimiter("&") mlabels((1) (2) (3)) prehead(\begin{tabular}{l*{@M}{c}} \hline \hline) postfoot(\hline \hline \end{tabular}) style(tex) substitute(_ \_) order() replace
drop _est_m1 _est_m2 _est_m3 
